package org.asg.dis.repository;

import org.asg.dis.model.ExpressStation;
import org.asg.dis.model.ExpressStationGeo;
import org.asg.dis.model.ExpressStationStatus;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface ExpressStationRepository extends JpaRepository<ExpressStation, Long> {
    @Query("SELECT e FROM ExpressStation e")
    List<ExpressStationGeo> findAllStationGeo();

    @Modifying
    @Query("UPDATE ExpressStation es SET es.status = :status WHERE es.id = :id")
    int updateStatus(@Param("id") Long id, @Param("status") ExpressStationStatus status);

    @Modifying
    @Query("UPDATE ExpressStation es SET es.staffAmount = :staffAmount WHERE es.id = :id")
    int updateStaffCount(@Param("id") Long id, @Param("staffAmount") Integer staffAmount);

    @Modifying
    @Query("UPDATE ExpressStation es SET es.courierAmount = :courierAmount WHERE es.id = :id")
    int updateCourierCount(@Param("id") Long id, @Param("courierAmount") Integer courierAmount);

}

